<template>
  <div>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="单位名称" prop="cName">
        <el-input
          v-model="queryParams.cName"
          placeholder="请输入单位名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="行业" prop="cIndustry">
        <el-select v-model="queryParams.cIndustry" clearable placeholder="请选择行业">
          <el-option
            v-for="dict in dict.type.product_industry"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
<!--        <el-input-->
<!--          v-model="queryParams.cIndustry"-->
<!--          placeholder="请输入行业"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
      </el-form-item>
      <el-form-item label="人员规模" prop="cScale">
        <el-select v-model="queryParams.cScale" clearable   placeholder="请选择人员规模">
          <el-option
            v-for="dict in dict.type.personnel_size"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
<!--        <el-input-->
<!--          v-model="queryParams.cScale"-->
<!--          placeholder="请输入人员规模"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
      </el-form-item>
      <el-form-item label="适配OS" prop="cOs">
        <el-select v-model="queryParams.cOs" clearable placeholder="请选择适配OS">
          <el-option
            v-for="dict in dict.type.audition_os"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
<!--        <el-input-->
<!--          v-model="queryParams.cOs"-->
<!--          placeholder="请输入适配OS"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
      </el-form-item>
<!--      <el-form-item label="适配平台" prop="cPlatform">-->
<!--        <el-input-->
<!--          v-model="queryParams.cPlatform"-->
<!--          placeholder="请输入适配平台"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="使用评价" prop="cEvaluate">-->
<!--        <el-input-->
<!--          v-model="queryParams.cEvaluate"-->
<!--          placeholder="请输入使用评价"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="应用系统名称" prop="cAppName">-->
<!--        <el-input-->
<!--          v-model="queryParams.cAppName"-->
<!--          placeholder="请输入应用系统名称"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="竣工日期" prop="cCompletionDate">-->
<!--        <el-input-->
<!--          v-model="queryParams.cCompletionDate"-->
<!--          placeholder="请输入竣工日期"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="建设周期" prop="cConstructionCycle">-->
<!--        <el-input-->
<!--          v-model="queryParams.cConstructionCycle"-->
<!--          placeholder="请输入建设周期"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['info:caseInfo:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['info:caseInfo:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['info:caseInfo:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['info:caseInfo:importPage']"
        >批量导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['info:caseInfo:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="data" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="id" />
      <el-table-column label="单位名称" align="center" prop="cName" />
      <el-table-column label="行业" align="center" prop="cIndustry" />
      <el-table-column label="应用场景" align="center" prop="cScene" />
      <el-table-column label="人员规模" align="center" prop="cScale" />
      <el-table-column label="适配OS" align="center" prop="cOs" />
      <el-table-column label="适配平台" align="center" prop="cPlatform" />
      <el-table-column label="建设内容" align="center" prop="cContent" />
      <el-table-column label="使用评价" align="center" prop="cEvaluate" />
      <el-table-column label="应用系统名称" align="center" prop="cAppName" />
      <el-table-column label="竣工日期" align="center" prop="cCompletionDate" />
      <el-table-column label="建设周期" align="center" prop="cConstructionCycle" />
      <el-table-column label="审核状态0:待审核 2:不合格 3:正常" align="center" prop="cState" >
        <template slot-scope="scope">
          <el-tag v-if="scope.row.cState === '0'" type="info">待审核</el-tag>
          <el-tag v-if="scope.row.cState === '1'" type="error">不合格</el-tag>
          <el-tag v-if="scope.row.cState === '2'" >正常</el-tag>
        </template>
      </el-table-column>

      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['info:caseInfo:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleDetail(scope.row)"
            v-hasPermi="['info:caseInfo:detail']"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['info:caseInfo:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import ListMixin from "@/minixs/list"
import request from "@/utils/request";
export default {
  name: "list",
  mixins:[ListMixin],
  dicts:['product_industry','personnel_size','audition_os'],
  data() {
    return {
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        cName: null,
        cIndustry: null,
        cScene: null,
        cScale: null,
        cOs: null,
        cPlatform: null,
        cContent: null,
        cEvaluate: null,
        cAppName: null,
        cCompletionDate: null,
        cConstructionCycle: null,
      },
      //   删除地址
      deletedUrl:"/info/caseInfo/"
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询案例信息列表 */
    getList() {
      this.loading = true;
      request({
        url: '/info/caseInfo/list',
        method: 'get',
        params: this.queryParams
      }).then(response => {
        this.data = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download('/info/caseInfo/export', {
        ...this.queryParams
      }, `案例信息_${new Date().getTime()}.xlsx`)
    },

    handleImport(){
      this.$emit("import-handle", {
        open: true,
        title: "批量导入",
        type:'IMPORT'
      })
    },
  }
};
</script>
